package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.DevicePropertyStatusRequestDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.dto.AddElderRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.ServicePropertiesVo;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.nursing.dto.DeviceDataListByDayRequestDto;
import com.zzyl.nursing.vo.DeviceDataListByDayRequestVo;
import com.zzyl.nursing.vo.DeviceDataListByWeekRequestVo;
import com.zzyl.nursing.vo.FamilyElderListVo;
import com.zzyl.nursing.vo.MemberElderVo;

import javax.validation.Valid;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

   
    @GetMapping("/queryServiceProperties/{iotId}")
    @ApiOperation("查询健康数据（新版）")
    public AjaxResult queryServiceProperties(@PathVariable String iotId){
        List<ServicePropertiesVo> list = familyMemberService.queryServiceProperties(iotId);
        return success(list);
    }

   
    @PostMapping("/QueryDevicePropertyStatus")
    @ApiOperation("查询健康数据（旧版）")
    public AjaxResult queryDevicePropertyStatus(@RequestBody DevicePropertyStatusRequestDto dto){
        List<ServicePropertiesVo> list = familyMemberService.queryDevicePropertyStatus(dto);
        return success(list);
    }

    
    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
    public AjaxResult queryDeviceDataListByDay( DeviceDataListByDayRequestDto dto){
        List<DeviceDataListByDayRequestVo> list = familyMemberService.queryDeviceDataListByDay(dto);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
    public AjaxResult queryDeviceDataListByWeek(DeviceDataListByDayRequestDto dto){
        List<DeviceDataListByWeekRequestVo> list = familyMemberService.queryDeviceDataListByWeek(dto);
        return success(list);
    }

    @PostMapping("/add")
    @ApiOperation("添加老人")
    public AjaxResult addElder(@Valid @RequestBody AddElderRequestDto dto){
        Boolean result = familyMemberService.addElder(dto);
        return success(result);
    }

    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult getMyElderList(){
        List<FamilyElderListVo> result = familyMemberService.getMyElderList();
        return success(result);
    }

    @GetMapping("/list-by-page")
    @ApiOperation("分页查询家人列表")
    public AjaxResult getMyElderListByPage(@RequestParam(value = "pageNum", required = false) Integer pageNum,
                                          @RequestParam(value = "pageSize", required = false) Integer pageSize){
        List<MemberElderVo> result = familyMemberService.getMyElderListByPage(pageNum, pageSize);
        return success(result);
    }

}
